package com.xd.clap.controller;

import com.xd.clap.entity.TaskAllocation;
import com.xd.clap.entity.request.PageParam;
import com.xd.clap.entity.response.AddTask;
import com.xd.clap.entity.response.Result;
import com.xd.clap.services.TaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/task")
public class TaskController {

    @Resource
    private TaskService taskService;


    /**
     * 添加事务
     * @param addTask
     * @return
     */
    @PostMapping("/addTask")
    public Result addTask(@RequestBody AddTask addTask){
        return taskService.addTask(addTask);
    }

    /**
     * 分页获取事务
     */
    @PostMapping("/getTask")
    public Result getTask(@RequestBody PageParam pageParam){
        return taskService.getTask(pageParam);
    }

    /**
     * 获取任务详情
     */
    @GetMapping("/getTaskInfo")
    public Result getTaskInfo(Integer id){
        return taskService.getTaskInfo(id);
    }

    /**
     * app端获取个人任务信息
     */
    @PostMapping("/getAppTask")
    public Result getAppTask(@RequestBody PageParam pageParam){
        return taskService.getAppTask(pageParam);
    }


    /**
     * 处理任务
     * @param taskAllocation
     * @return
     */
    @PostMapping("/updateTask")
    public Result updateTask(@RequestBody TaskAllocation taskAllocation){
        return taskService.updateTask(taskAllocation);
    }


    /**
     * 删除任务
     * @param id
     * @return
     */
    @GetMapping("/deleteTask")
    public Result deleteTask(Integer id){
        return taskService.deleteTask(id);
    }
}
